<?php require_once('Connections/locamedicadmin.php'); ?>

<?php include('userValidation.php'); ?>

<?php include('functions.php'); ?>

<?php 

if ((isset($_GET['manufactureid'])) && ($_GET['manufactureid'] != "")) {

	$deleteGoTo = "manufacture_list.php";
 
	$colname_productsbymanufacture = "-1";
	if (isset($_GET['manufactureid'])) {
	  $colname_productsbymanufacture = (get_magic_quotes_gpc()) ? $_GET['manufactureid'] : addslashes($_GET['manufactureid']);
	}
	mysql_select_db($database_locamedicadmin, $locamedicadmin);
	$query_productsbymanufacture = sprintf("SELECT product_id FROM csre_product WHERE manufacture_id = %s", $colname_productsbymanufacture);
	$productsbymanufacture = mysql_query($query_productsbymanufacture, $locamedicadmin) or die(mysql_error());
	$row_productsbymanufacture = mysql_fetch_assoc($productsbymanufacture);
	$totalRows_productsbymanufacture = mysql_num_rows($productsbymanufacture);
  
	if ($totalRows_productsbymanufacture > 0) {

		header(sprintf("Location: %s?manufactureused=true", $deleteGoTo));

	} else {


	  $deleteSQL = sprintf("DELETE FROM csre_manufacture WHERE manufacture_id=%s",
						   GetSQLValueString($_GET['manufactureid'], "int"));
	
	  mysql_select_db($database_locamedicadmin, $locamedicadmin);
	  $Result1 = mysql_query($deleteSQL, $locamedicadmin) or die(mysql_error());
	
	  if (isset($_SERVER['QUERY_STRING'])) {
		$deleteGoTo .= (strpos($deleteGoTo, '?')) ? "&" : "?";
		$deleteGoTo .= $_SERVER['QUERY_STRING'];
	  }
	  header(sprintf("Location: %s", $deleteGoTo));
  }
  mysql_free_result($productsbymanufacture);
}


?>